home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 2.5)
-
- import cPickle
- import inspect
- import shutil
- import re
- import traceback
- import random
- import types
- import logging
- from itertools import izip
- from xhtmltools import urlencode
- HTMLPattern = re.compile('^.*<body.*?>(.*)</body\\s*>', re.S)
- attrPattern = re.compile('^(.*?)@@@(.*?)@@@(.*)$')
- resourcePattern = re.compile('^resource:(.*)$')
- rawAttrPattern = re.compile('^(.*?)\\*\\*\\*(.*?)\\*\\*\\*(.*)$')
- _unicache = { }
- _escapecache = { }
-
- def quoteattr(orig):
- orig = unicode(orig)
- return orig.replace(u'"', u'"')
-
-
- def escape(orig):
- orig = unicode(orig)
-
- try:
- return _escapecache[orig]
- except:
- _escapecache[orig] = orig.replace('&', '&').replace('<', '<').replace('>', '>')
- return _escapecache[orig]
-
-
- defaultEncoding = 'iso-8859-1'
- _utf8cache = { }
-
- def toUTF8Bytes(string, encoding = None):
-
- try:
- return _utf8cache[(string, encoding)]
- except KeyError:
- result = None
- if isinstance(string, types.UnicodeType):
- result = string.encode('utf-8')
- elif not isinstance(string, types.StringType):
- string = str(string)
-
- if result is None and encoding is not None:
-
- try:
- decoded = string.decode(encoding, 'replace')
- except (UnicodeDecodeError, ValueError, LookupError):
- pass
-
- result = decoded.encode('utf-8')
-
- if result is None:
- result = string.decode(defaultEncoding, 'replace').encode('utf-8')
-
- _utf8cache[(string, encoding)] = result
- return _utf8cache[(string, encoding)]
-
-
-
- def toUni(orig, encoding = None):
-
- try:
- return _unicache[orig]
- except:
- if isinstance(orig, types.UnicodeType):
- return orig
- elif not isinstance(orig, types.StringType):
- _unicache[orig] = unicode(orig)
- else:
- orig = toUTF8Bytes(orig, encoding)
- _unicache[orig] = unicode(orig, 'utf-8')
- return _unicache[orig]
-
-
-
- def generateId():
- return 'tmplcomp%08d' % random.randint(0, 99999999)
-
-